package Enums;

public enum Cask {
    FIRKIN(0),
    PIN(1),
    KILDERKIN(2),
    BARREL(3),
    HALF_BARREL(4);
    
    private int type;

    Cask(final int type) {
            this.type = type;
    }

    public int getType() {
            return type;
    }

    public static Cask getType(final String type) {
            return getType(Integer.parseInt(type));
    }
    
    public static Cask getType(final int type) {
        switch (type) {
        case 0:
            return FIRKIN;
        case 1:
            return PIN;
        case 2:
            return KILDERKIN;
        case 3:
            return BARREL;
        case 4:
            return HALF_BARREL;
        default:
            throw new EnumConstantNotPresentException(LabResult.class, String.valueOf(type));
        }
    }
    
    public static int getTypeByName(final String str) {
        if(str.equals("FIRKIN")){
            return 0;
        } else if(str.equals("PIN")){
            return 1;
        } else if(str.equals("KILDERKIN")){
            return 2;
        } else if(str.equals("BARREL")){
            return 3;
        } else if(str.equals("HALF_BARREL")){
            return 4;
        } else {
            return 0;
        }
    }
    
    public static String getTypeDescription(final int type) {
        switch (type) {
            case 0:
                return "Firkin";
            case 1:
                return "Pin";
            case 2:
                return "Kilderkin";
            case 3:
                return "Barrel";
            case 4:
                return "1/2 Barrel";
            default:
                throw new EnumConstantNotPresentException(LabResult.class, String.valueOf(type));
        }
    }
    
    public static double getTypeVolme(final int type) {
        switch (type) {
            case 0:
                return 9;
            case 1:
                return 4.5;
            case 2:
                return 18;
            case 3:
                return 36;
            case 4:
                return 15.5;
            default:
                throw new EnumConstantNotPresentException(LabResult.class, String.valueOf(type));
        }
    }

}
